package com.sunlee.admin.api.module.sys.redis;

import com.sunlee.common.core.redis.RedisKeys;
import com.sunlee.common.core.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 参数管理-缓存
 *
 * @author sunlee
 */
@Component
public class SysParamsRedis {

    @Autowired
    private RedisUtils redisUtils;

    public void delete(List<String> paramCodes) {
        paramCodes.forEach(code -> redisUtils.hmDelete(RedisKeys.getSysParamsKey(), code));
    }

    public void set(String paramCode, String paramValue) {
        if (paramValue == null) {
            return;
        }
        String key = RedisKeys.getSysParamsKey();
        redisUtils.hmSet(key, paramCode, paramValue);
    }

    public String get(String paramCode) {
        String key = RedisKeys.getSysParamsKey();
        return (String) redisUtils.hmGet(key, paramCode);
    }

}
